home *** CD-ROM | disk | FTP | other *** search
- (*===========================================================================*)
- (* Procedure for initializing *)
- (* *)
- (* Copyright 1988, 1989, 1990, 1991, 1992 by H. Roy Engehausen. All *)
- (* rights reserved. *)
- (* *)
- (*===========================================================================*)
-
- {$UNDEF DEBUG}
-
- UNIT BBINIT;
-
- {$O+} {This procedure gets overlayed}
-
- INTERFACE
-
- PROCEDURE initialize;
- PROCEDURE tinit;
- PROCEDURE tclose;
-
- IMPLEMENTATION
-
- USES
- CRT,
- DOS,
- bbaux,
- bbdummy,
- bbfwd,
- bbmisc,
- bbmisc4,
- bbopr,
- bbrunerr,
- bbsdata,
- bbsess,
- bbsrt,
- bbstr,
- bbtask,
- bbtime,
- bbuf,
- bbwin;
-
- CONST debug = FALSE;
-
- {$I BBTINIT.PAS}
-
- PROCEDURE initialize;
-
- VAR
- buff_size : WORD;
- i : WORD;
- min_time : LONGINT;
- work_tcb : tcb_ptr;
-
- BEGIN;
-
- (*-------------------------------------------------------------------------*)
- (* Initialize *)
- (*-------------------------------------------------------------------------*)
-
- shutdown_switch := FALSE;
- main_switch := FALSE;
-
- fwd_command := '';
-
- (*-------------------------------------------------------------------------*)
- (* Initialize main tcb -- Put the call and stuff in the TCB *)
- (*-------------------------------------------------------------------------*)
-
- active_tcb^.window := window_monitor;
- active_tcb^.max_pac := 128;
- active_tcb^.tcb_name := '';
-
- active_tcb^.tcb_type := th_main;
- active_tcb^.tcb_ignore_lc := TRUE;
- active_tcb^.tcb_ignore_port_chan := TRUE;
- active_tcb^.tcb_sysop_pw_ok := TRUE;
- active_tcb^.tcb_never_kill := TRUE;
-
- active_tcb^.uid_data.user_i_ptr := find_uid(opt_block.this_bb_sign);
-
- IF active_tcb^.uid_data.user_i_ptr <> NIL THEN
- active_tcb^.uid_data := get_uid(active_tcb^.uid_data.user_i_ptr)^
- ELSE
- BEGIN;
- uid_init(@active_tcb^.uid_data);
- active_tcb^.uid_data.user_id := opt_block.this_bb_sign;
- END;
-
- active_tcb^.uid_data.user_class := user_c_lsu;
- active_tcb^.uid_data.user_last := current_day_time;
- active_tcb^.uid_data.user_port := 'L';
-
- active_tcb^.last_l_time := active_tcb^.uid_data.user_l_time;
-
- IF active_tcb^.uid_data.user_i_ptr = NIL THEN
- add_uid(@active_tcb^.uid_data)
- ELSE
- update_uid(@active_tcb^.uid_data);
-
- (*-------------------------------------------------------------------------*)
- (* Initialize the TNCs *)
- (*-------------------------------------------------------------------------*)
-
- {$IFDEF DEBUG}
- WRITELN('TNCinit');
- {$ENDIF}
-
- tinit;
-
- (*-----------------------------------------------------------------------*)
- (* Schedule forwards *)
- (*-----------------------------------------------------------------------*)
-
- min_time := current_day_time + ticks_per_min + (ticks_per_min SHR 1);
-
- active_port := ring_port;
-
- REPEAT
-
- WITH active_port^ DO
- BEGIN;
-
- IF port_no_out_fwd THEN
- sked_fwd := max_time
- ELSE
- BEGIN;
- sked_fwd := time_next_hour(fwd_min);
- IF sked_fwd < min_time THEN
- sked_fwd := min_time;
- END;
-
- active_port := next_port;
-
- END;
-
- UNTIL active_port = ring_port;
-
- (*-------------------------------------------------------------------------*)
- (* Start operator's task *)
- (*-------------------------------------------------------------------------*)
-
- {$IFDEF DEBUG}
- WRITELN('OPRinit');
- {$ENDIF}
-
- work_tcb := task_create(@operator_task_start, operator_stack_size);
- IF work_tcb = NIL THEN
- BEGIN;
- WRITELN('***** FATAL ERROR *****');
- WRITELN('Could not start operator task');
- HALT;
- END;
-
- WITH work_tcb^ DO
- BEGIN;
- tcb_type := th_operator;
- tcb_name := '';
- tcb_console := TRUE;
- tcb_port := @dummy_port;
- channel := 0;
- port_chan_s := 'LO';
- window := window_operator;
- w_color := opt_block.operator_color;
- tcb_never_kill := TRUE;
- tcb_sysop_pw_ok := TRUE;
-
- IF opt_block.opt_suppress_pfx THEN
- max_pac := special_max_pac_wop
- ELSE
- max_pac := special_max_pac_wp;
-
- END;
-
- work_tcb^.uid_data.user_i_ptr := find_uid(opt_block.sysop_sign);
-
- IF work_tcb^.uid_data.user_i_ptr <> NIL THEN
- work_tcb^.uid_data := get_uid(work_tcb^.uid_data.user_i_ptr)^
- ELSE
- BEGIN;
- uid_init(@work_tcb^.uid_data);
- work_tcb^.uid_data.user_id := opt_block.sysop_sign;
- END;
-
- work_tcb^.uid_data.user_class := user_c_lsu;
- work_tcb^.uid_data.user_last := current_day_time;
- work_tcb^.uid_data.user_port := 'L';
-
- work_tcb^.last_l_time := work_tcb^.uid_data.user_l_time;
-
- IF work_tcb^.uid_data.user_i_ptr = NIL THEN
- add_uid(@work_tcb^.uid_data)
- ELSE
- update_uid(@work_tcb^.uid_data);
-
- (*-------------------------------------------------------------------------*)
- (* Start forward TCB *)
- (*-------------------------------------------------------------------------*)
-
- {$IFDEF DEBUG}
- WRITELN('FWDinit');
- {$ENDIF}
-
- work_tcb := task_create(@forward_task_start, forward_stack_size);
- IF work_tcb = NIL THEN
- BEGIN;
- WRITELN('***** FATAL ERROR *****');
- WRITELN('Could not start forward process task');
- HALT;
- END;
-
- WITH work_tcb^ DO
- BEGIN;
- tcb_type := th_fwd_control;
- uid_data := ring_tcb^.uid_data;
- uid_data.user_i_ptr := ring_tcb^.uid_data.user_i_ptr;
- tcb_console := TRUE;
- tcb_port := @dummy_port;
- tcb_name := '';
- max_pac := special_max_pac_wp;
- window := window_connect;
- w_color := opt_block.operator_color;
- tcb_sysop_pw_ok := TRUE;
- tcb_never_kill := TRUE;
-
- END;
-
- (*-------------------------------------------------------------------------*)
- (* Start auxiliary processes -- One per port *)
- (*-------------------------------------------------------------------------*)
-
- {$IFDEF DEBUG}
- WRITELN('AUXinit');
- {$ENDIF}
-
- active_port := ring_port;
-
- REPEAT
-
- active_tcb^.tcb_port := active_port;
-
- IF NOT active_port^.port_sub_port THEN
- BEGIN;
-
- {$IFDEF DEBUG}
- WRITELN('Activate aux -- ', active_port^.port_char);
- DELAY(1000);
- {$ENDIF}
-
- IF (active_port^. port_type = port_modem)
- OR (active_port^. port_type = port_null_modem) THEN
- work_tcb := task_create(@aux_task_start, teleaux_stack_size)
- ELSE
- work_tcb := task_create(@aux_task_start, auxilary_stack_size);
-
- IF work_tcb = NIL THEN
- BEGIN;
- WRITELN('***** FATAL ERROR *****');
- WRITELN('Could not start aux process');
- HALT;
- END;
-
- active_port^.aux_thread := work_tcb;
-
- WITH work_tcb^ DO
- BEGIN;
- tcb_type := th_aux;
- tcb_port := active_port;
- port_chan_s[1] := active_port^.port_char;
- port_chan_s[2] := '0';
- channel := 0;
- uid_data := ring_tcb^.uid_data;
- tcb_ignore_lc := TRUE;
- tcb_ignore_port_chan := TRUE;
- tcb_name := '';
- max_pac := special_max_pac_wp;
- window := window_monitor;
- w_color := active_port^.port_color;
- tcb_sysop_pw_ok := TRUE;
- tcb_never_kill := TRUE;
- END;
-
- END;
-
- active_port := active_port^.next_port;
-
- UNTIL active_port = ring_port;
-
- (*-------------------------------------------------------------------------*)
- (* Save count of overhead tasks *)
- (*-------------------------------------------------------------------------*)
-
- overhead_tcb_count := alive_tcb_count;
-
- END;
-
- END.